package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import java.util.ArrayList;
/**
 * 经验等级表
 */
public class LevelUpCfg extends BaseCfg<LevelUpCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "level_up";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.LevelUpCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 5;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","玩家经验","最大体力","升级恢复体力","英雄经验",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","playerExp","maxEnergy","recovery","heroExp",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","playerExp","maxEnergy","recovery","heroExp",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,-1872068740,-983750388,-799113323,811304899,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","long","int","int","long",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Long.class,Integer.class,Integer.class,Long.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 玩家经验
	 */
	private long playerExp;
	
	/**
	 * 最大体力
	 */
	private int maxEnergy;
	
	/**
	 * 升级恢复体力
	 */
	private int recovery;
	
	/**
	 * 英雄经验
	 */
	private long heroExp;
	
	
	
	public static LevelUpCfg builder() {
		LevelUpCfg levelUpCfg = new LevelUpCfg();
		return levelUpCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 玩家经验
	 */
	public long getPlayerExp() {
		return playerExp;
	}
	
	/**
	 * 最大体力
	 */
	public int getMaxEnergy() {
		return maxEnergy;
	}
	
	/**
	 * 升级恢复体力
	 */
	public int getRecovery() {
		return recovery;
	}
	
	/**
	 * 英雄经验
	 */
	public long getHeroExp() {
		return heroExp;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.playerExp;
        values[2] = this.maxEnergy;
        values[3] = this.recovery;
        values[4] = this.heroExp;
        return values;
	}
	
	protected LevelUpCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.playerExp = (long)vals[1];
		this.maxEnergy = (int)vals[2];
		this.recovery = (int)vals[3];
		this.heroExp = (long)vals[4];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.playerExp);
        map.put(keys[2], this.maxEnergy);
        map.put(keys[3], this.recovery);
        map.put(keys[4], this.heroExp);
        return map;
    }
    
    protected LevelUpCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.playerExp = (long)map.get(keys[1]);
   		this.maxEnergy = (int)map.get(keys[2]);
   		this.recovery = (int)map.get(keys[3]);
   		this.heroExp = (long)map.get(keys[4]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.playerExp);
        obj.put(keys[2], this.maxEnergy);
        obj.put(keys[3], this.recovery);
        obj.put(keys[4], this.heroExp);
        return obj;
    }
    
    protected LevelUpCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.playerExp = obj.getLongValue(keys[1]);
	    this.maxEnergy = obj.getIntValue(keys[2]);
	    this.recovery = obj.getIntValue(keys[3]);
	    this.heroExp = obj.getLongValue(keys[4]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeLong(this.playerExp);
	    byteBuf.writeInt(this.maxEnergy);
	    byteBuf.writeInt(this.recovery);
	    byteBuf.writeLong(this.heroExp);
    }
	
	protected LevelUpCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.playerExp = byteBuf.readLong(null);
	    this.maxEnergy = byteBuf.readInt(null);
	    this.recovery = byteBuf.readInt(null);
	    this.heroExp = byteBuf.readLong(null);
	    return this;
	}
	
	public LevelUpCfg deepCopy(){
		LevelUpCfg levelUpCfg = null;
		try {
			levelUpCfg = (LevelUpCfg) super.clone();
			return levelUpCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return levelUpCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
